home *** CD-ROM | disk | FTP | other *** search
-
- /**************************************************************************
- * *
- * This code is developed by Adam Li. This software is an *
- * implementation of a part of one or more MPEG-4 Video tools as *
- * specified in ISO/IEC 14496-2 standard. Those intending to use this *
- * software module in hardware or software products are advised that its *
- * use may infringe existing patents or copyrights, and any such use *
- * would be at such party's own risk. The original developer of this *
- * software module and his/her company, and subsequent editors and their *
- * companies (including Project Mayo), will have no liability for use of *
- * this software or modifications or derivatives thereof. *
- * *
- * Project Mayo gives users of the Codec a license to this software *
- * module or modifications thereof for use in hardware or software *
- * products claiming conformance to the MPEG-4 Video Standard as *
- * described in the Open DivX license. *
- * *
- * The complete Open DivX license can be found at *
- * http://www.projectmayo.com/opendivx/license.php . *
- * *
- **************************************************************************/
-
- /************************************************************************
- *
- * dec_engine.cpp, Decoder Engines
- *
- * Copyright (C) 2000 DivX Networks
- *
- * Adam Li
- * Andrea Graziani
- *
- * DivX Advance Research Center <darc@projectmayo.com>
- *
- ************************************************************************/
-
- #include <stdio.h>
- #include <stdlib.h>
-
- #include "stdafx.h"
- #include "codec.h"
- #include "decore.h"
-
- long codec::decBegin(LPARAM lParam1, LPARAM lParam2)
- {
- int x_dim, y_dim, size;
-
- BITMAPINFO *lpbiInput, *lpbiOutput;
- BITMAPV4HEADER *infohdr_i;
- DEC_PARAM dec_param;
- DEC_SET dec_set;
-
- lpbiInput = (BITMAPINFO *)lParam1;
- lpbiOutput = (BITMAPINFO *)lParam2;
-
- infohdr_i = (BITMAPV4HEADER *)&(lpbiInput->bmiHeader);
- x_dim = infohdr_i->bV4Width;
- y_dim = infohdr_i->bV4Height;
- size = x_dim * y_dim;
- dec_param.x_dim = x_dim;
- dec_param.y_dim = y_dim;
- dec_param.color_depth = lpbiOutput->bmiHeader.biBitCount;
-
- decore((long) this, DEC_OPT_INIT, &dec_param, NULL);
-
- // The postprocessing of the decore can be hard coded here for now.
- // The filter that produces message will be implemented later.
-
- // postprcc_level = 0 ----> no post processing
- // postproc_level = 1 ~ 9 ----> horizontal deblocking only
- // postproc_level = 10 ~ 19 ----> hor. + ver. deblocking
- // postproc_level = 20 ~ 29 ----> full deblocking + deringing
- // postproc_level = 30 ~ 39 ----> above + deblocking chroma hor.
- // postproc_level = 40 ~ 49 ----> above + deblocking chroma ver.
- // postproc_level = 50 ~ 59 ----> above + deringing chroma
-
- dec_set.postproc_level = 0;
-
- decore((long) this, DEC_OPT_SETPP, &dec_set, NULL);
-
- return ICERR_OK;
- }
-
- long codec::decEnd(LPARAM lParam1, LPARAM lParam2)
- {
- decore((long) this, DEC_OPT_RELEASE, NULL, NULL);
-
- return ICERR_OK;
- }
-
- long codec::decDecode(LPARAM lParam1, LPARAM lParam2)
- {
- ICDECOMPRESS *icc = (ICDECOMPRESS *)lParam1;
- ICOPEN *ico = (ICOPEN *)lParam2;
-
- DWORD flags = icc->dwFlags;
-
- BITMAPV4HEADER *lpbihdr_i, *lpbihdr_o;
- DEC_FRAME dec_frame;
-
- lpbihdr_i = (BITMAPV4HEADER *)icc->lpbiInput;
- lpbihdr_o = (BITMAPV4HEADER *)icc->lpbiOutput;
-
- lpbihdr_o->bV4V4Compression = BI_RGB;
-
- dec_frame.length = icc->lpbiInput->biSizeImage;
- dec_frame.bitstream = icc->lpInput;
- dec_frame.bmp = icc->lpOutput;
-
- if ((flags & ICDECOMPRESS_HURRYUP) | (flags & ICDECOMPRESS_UPDATE)) {
- dec_frame.render_flag = 0;
- }
- else {
- dec_frame.render_flag = 1;
- }
-
- decore((long) this, 0, &dec_frame, NULL);
-
- return ICERR_OK;
- }
-
- long codec::decSetPostProcessing(LPARAM lParam1, LPARAM lParam2)
- {
- DEC_SET *dec_set = (DEC_SET *)lParam1;
-
- decore((long) this, DEC_OPT_SETPP, dec_set, NULL);
-
- return ICERR_OK;
- }
-